package com.lwj.liwanjia.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.lwj.liwanjia.R;
import com.lwj.liwanjia.bean.DbBean;

import java.util.List;

/**
 * Created by 001 on 2017/9/6.
 */

public class DbAdapter extends BaseAdapter {

    private Context mContext;
    private List<DbBean> mList;

    public DbAdapter(Context mContext,List<DbBean> mList) {
        this.mContext = mContext;
        this.mList = mList;
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        if (convertView == null) {
            convertView = View.inflate(mContext, R.layout.adapter_db, null);
        }

        TextView tv_name = (TextView) convertView.findViewById(R.id.tv_name);
        DbBean bean = mList.get(position);

        tv_name.setText(bean.name);

        return convertView;
    }
}
